api ={
    GetDate:function () {
        var date=new Date()
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h=h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        minute = minute < 10 ? ('0' + minute) : minute;
        var second=date.getSeconds();
        second=second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    },
    GET: function(url, data, callback) {
        axios({
            method: 'get',
            url: url,
            params: data,
            headers: {
                'Authorization': localStorage.getItem('token'),
                // 'Redirect-Header': false,
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    POST: function(url, data, callback) {
        axios({
            method: 'post',
            url: url,
            data: JSON.stringify(data),
            headers: {
                'Authorization': localStorage.getItem('token'),
                //   'Redirect-Header': false,
                'Content-Type': 'application/json',
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    POSTData: function(url, data, callback) {
        axios({
            method: 'post',
            url: url,
            data: data,
            headers: {
                'Authorization': localStorage.getItem('token'),
                //  'Redirect-Header': false
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    PUT: function(url, data, callback) {
        axios({
            method: 'put',
            url: url,
            data: data,
            headers: {
                'Authorization': localStorage.getItem('token'),
                //  'Redirect-Header': false,
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    DELETE: function(url, data, callback) {
        axios({
            method: 'post',
            url: url+'/delete',
            data: JSON.stringify(data),
            headers: {
                'Authorization': localStorage.getItem('token'),
                // 'Redirect-Header': false,
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    saveOrUpdate: function(data, callback) {
        axios({
            method: 'post',
            url: '/form/saveorupdate',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    getData: function(data, callback) {
        axios({
            method: 'post',
            url: '/form/getbonamedata',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    createProcess: function(data, callback) {
        axios({
            method: 'post',
            url: '/form/processcreate',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    submitProcessData: function(data, callback) {
        axios({
            method: 'post',
            url: '/form/submitProcess',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    getNextNodeInfo: function(data, callback) {
        axios({
            method: 'post',
            url: '/form/getNextNodeInfo',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    getalluser : function(data, callback) {
        axios({
            method: 'post',
            url: '/form/getalluser',
            data: JSON.stringify(data),
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                callback(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    getcookie :function(name){
        var acookie = document.cookie.split("; ");
        for (var i = 0; i < acookie.length; i++) {
            var arr = acookie[i].split("=");
            if (name == arr[0]) {
                if (arr.length > 1)
                    return unescape(arr[1]);
                else
                    return "";
            }
        }
        return "";
    }
}